package cn.tedu.javagame.shoot;

import javax.swing.*;
import java.awt.*;

public class Heart extends FlyObject{
    int type;//0加血 1加火力 2加金币
    int state;
    public Heart(){
        imgs = new Image[9];
        img = new ImageIcon("plane/qq00.png").getImage();
        for(int i=0;i<imgs.length;i++){
            imgs[i] = new ImageIcon("plane/qq0"+i+".png").getImage();
        }
        this.x = (int)(Math.random()*(ShootFrame.WIDTH-img.getWidth(null)));
        this.y = -img.getHeight(null);
        this.type = (int)(Math.random()*3);
        this.state = (int)(Math.random()*2);
    }
    public void move(){
        this.y+=speed;
        if(this.state==0){
            this.x-=5;
        }
        if(this.state==1){
            this.x+=5;
        }
        //碰到边界的时候
        if(this.x<=0){this.state=1;}
        if(this.x+this.img.getWidth(null)>=ShootFrame.WIDTH){this.state=0;}
    }
}
